<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加借阅 - 图书管理系统</title>
    <link rel="stylesheet" href="/librarymanagementsystem/css/main.css">
</head>
<body>
    <div class="container">
        <header>
            <h1>图书管理系统</h1>
            <nav>
                <ul>
                    <li><a href="/librarymanagementsystem/index.html">首页</a></li>
                    <li><a href="/librarymanagementsystem/book_page.html">图书管理</a></li>
                    <li><a href="/librarymanagementsystem/borrow_page.html">借阅管理</a></li>
                    <li><a href="/librarymanagementsystem/borrow_add.html" class="active">添加借阅</a></li>
                </ul>
            </nav>
        </header>
        
        <main>
            <h2>添加借阅</h2>
            
            <form id="borrow-form">
                <input type="hidden" id="book-id" name="book-id">
                
                <div class="form-section">
                    <h3>图书信息</h3>
                    
                    <div id="book-selection" style="display: none;">
                        <div class="form-group">
                            <label for="book-select">选择图书</label>
                            <select id="book-select" name="book-select">
                                <!-- 图书选项将通过JavaScript动态加载 -->
                            </select>
                        </div>
                    </div>
                    
                    <div id="book-info">
                        <!-- 选中的图书信息将通过JavaScript动态显示 -->
                        <p>请选择一本图书</p>
                    </div>
                </div>
                
                <div class="form-section">
                    <h3>借阅信息</h3>
                    
                    <div class="form-group">
                        <label for="borrower-name">借阅人姓名</label>
                        <input type="text" id="borrower-name" name="borrower-name" required>
                    </div>
                    
                    <div class="form-group">
                        <label for="borrower-phone">借阅人电话</label>
                        <input type="tel" id="borrower-phone" name="borrower-phone">
                    </div>
                    
                    <div class="form-group">
                        <label for="borrow-date">借阅日期</label>
                        <input type="date" id="borrow-date" name="borrow-date" required>
                    </div>
                    
                    <div class="form-group">
                        <label for="return-date">应还日期</label>
                        <input type="date" id="return-date" name="return-date" required>
                    </div>
                </div>
                
                <div class="form-actions">
                    <button type="submit" class="btn">保存</button>
                    <a href="/librarymanagementsystem/borrow_page.html" class="btn">取消</a>
                </div>
            </form>
        </main>
        
        <footer>
            <p>&copy; 2025 图书管理系统</p>
        </footer>
    </div>
    
    <script src="/librarymanagementsystem/js/jquery-3.2.1.js"></script>
    <script src="/librarymanagementsystem/js/borrow.js"></script>
    <script>
        // 设置默认的借阅日期为今天
        $(document).ready(function() {
            const today = new Date();
            const todayString = today.toISOString().split('T')[0];
            $("#borrow-date").val(todayString);
            
            // 设置默认的应还日期为14天后
            const returnDate = new Date(today);
            returnDate.setDate(today.getDate() + 14);
            const returnDateString = returnDate.toISOString().split('T')[0];
            $("#return-date").val(returnDateString);
            
            // 检查URL参数，如果没有bookId参数，则显示图书选择下拉列表
            const urlParams = new URLSearchParams(window.location.search);
            if (!urlParams.has('bookId')) {
                $("#book-selection").show();
            }
        });
    </script>
</body>
</html> 